const curEnv = process.env.ENV
const config = {
	// 环境变量
	envVariable: {
		// 本地开发环境
		dev: {
			localhost: {
				// 硕果
				resHost: 'http://127.0.0.1:8888',
				port: 8080
			},
			sg: {
				// 硕果
				resHost: 'http://192.168.18.111:8888',
				port: 8090
			},
			lj: {
				// 刘靖
				resHost: 'http://192.168.18.112:8888',
				port: 8091
			},
			jc: {
				// 金财
				resHost: 'http://192.168.18.113:8888',
				port: 8092
			},
			xy: {
				// 贤园
				resHost: 'http://192.168.18.168:8888',
				port: 8093
			},
			xp: {
				// 新普
				resHost: 'http://192.168.18.188:8888',
				port: 8094
			}
		},
		// 测试环境
		stg: {
			resHost: 'https://jytztest.tdribigdata.com'
		},
		// 生产环境
		prd: {
			resHost: 'https://jytz.tdribigdata.com'
		}
	}
}
// 开发环境连接谁的环境
let envConf = config.envVariable[curEnv]
if (curEnv === 'dev') {
	const params = process.env.npm_config_argv || process.env.npm_lifecycle_script
	const paramArr = typeof params === 'string' ? (params.match(/--dev=(\w*)/) || []) : []

	envConf = envConf[require('yargs').argv.dev || paramArr[1] || 'localhost']
}
const host = envConf ? envConf.resHost : config.envVariable.dev.resHost

module.exports = {
	publicPath: '/' + process.env.npm_package_name,
	outputDir: 'dist',
	host,
	port: (envConf ? envConf.port : config.envVariable.dev.port) || 8080,
	baseURL: host + '/szzBim/api'
}
